#include <iostream>
#include <math.h>
#include <vector>
#include <string.h>
using namespace std;
const int inf=0x7fffffff;


struct coin{
	int num,value,weight=1;
};


struct coin2{
	int weight,value;
};


int main(){
	int n,t,ans=inf;
	vector<coin2> v;
	scanf("%d%d",&n,&t);
	coin a[n];
	for(int i=0;i<n;i++)
		scanf("%d",&a[i].value);
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i].num);
		sum += a[i].num*a[i].value;
		coin2 l;
		int num=1,suml=0;
		while(suml < a[i].num){
			l.value = a[i].value*num;
			l.weight = a[i].weight*num;
			v.push_back(l);
			suml += num;
			num *= 2;
		}
		num = (num/2)-(suml-a[i].num);
		l.value = a[i].value*num;
		l.weight = a[i].weight*num;
		v[v.size()-1] = l;
	}
	int dp_b[sum-t+1],dp_j[sum+1];
	
	
	for(int i=0;i<=sum-t;i++)
		dp_b[i] = inf;
	dp_b[0] = 0;
	
	
	for(int i=0;i<=sum;i++){
		dp_j[i] = inf;
	}
	dp_j[0] = 0;
	
	
	//b
	for(int i=1;i<=n;i++)
		for(int j=a[i-1].value;j<=sum-t;j++)
			dp_b[j] = min(dp_b[j],dp_b[j-a[i-1].value]==inf?inf:dp_b[j-a[i-1].value]+a[i-1].weight);
	
	
	//j
	for(int i=0;i<v.size();i++)
		for(int j=sum;j>=v[i].value;j--)
			dp_j[j] = min(dp_j[j],dp_j[j-v[i].value]==inf?inf:dp_j[j-v[i].value]+v[i].weight);
	
//	for(int i=0;i<=sum;i++)
//		cout<<(dp_j[i]==inf?-1:dp_j[i])<<" ";
//	cout<<endl;
//	
//	for(int i=0;i<=sum-t;i++)
//		cout<<(dp_b[i]==inf?-1:dp_b[i])<<" ";
//	cout<<endl;
//	
//	cout<<dp_j[75]<<" "<<dp_b[5]<<endl;
	
	//cmp
	for(int i=0;i<=sum-t;i++)
		ans = min(ans,dp_b[i]+dp_j[i+t]>=0?dp_b[i]+dp_j[i+t]:inf);
	printf("%d",(ans==inf?-1:ans));
	return 0;
}
